﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NHibernate;
using Project.Web.Base.Utility;
using Project.Web.Base;

namespace Sample.Web.Base
{
	public abstract class BaseModel
	{
		public BaseModel()
		{
			InjectBizObject.Inject(this);
		}

		/// <summary>
		/// 导出对象
		/// </summary>
		public ExportHelper ExportObject
		{
			get;
			set;
		}

		/// <summary>
		/// Count
		/// </summary>
		protected int count;

		/// <summary>
		/// 分页对象
		/// </summary>
		private PaginateHelper paginateHelperObject;
		public PaginateHelper PaginateHelperObject
		{
			get
			{
				if (paginateHelperObject == null)
					paginateHelperObject = PaginateHelper.ConstructPaginate(0, 0, 0);
				return paginateHelperObject;
			}
			set
			{
				paginateHelperObject = value;
			}
		}

		private SelectList emptySelectList;
		/// <summary>
		/// 空列表
		/// </summary>
		public SelectList EmptySelectList
		{
			get
			{
				if (emptySelectList != null)
					return emptySelectList;
				List<SelectListItem> list = new List<SelectListItem>();
				emptySelectList = SelectListHelper.InsertFirstOption(new SelectList(list), "-- 请选择 --", "");
				return emptySelectList;
			}
		}

		private SelectList bitSelectList;
		/// <summary>
		/// 布尔型选择列表
		/// </summary>
		public SelectList BitSelectList
		{
			get
			{
				if (bitSelectList != null)
					return bitSelectList;
				SelectListItem item1 = new SelectListItem();
				item1.Text = "是";
				item1.Value = true.ToString();
				SelectListItem item2 = new SelectListItem();
				item2.Text = "否";
				item2.Value = false.ToString();
				IList<SelectListItem> items = new List<SelectListItem>();
				items.Add(item1);
				items.Add(item2);
				bitSelectList = SelectListHelper.ComposeSelectListFromCollect(items, x => x.Value, x => x.Text, "--请选择--", "");
				return bitSelectList;
			}
		}
	}
}